delimiter $$

CREATE DATABASE `lapidb` /*!40100 DEFAULT CHARACTER SET latin1 */$$


delimiter $$

CREATE TABLE `centrodeportivo` (
  `ID_CentroDeportivo` int(11) NOT NULL,
  `Descripcion` text,
  `Activo` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`ID_CentroDeportivo`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1$$

delimiter $$

CREATE TABLE `deportes` (
  `ID_Deportes` int(11) NOT NULL,
  `Descripcion` text,
  `Activo` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`ID_Deportes`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1$$

delimiter $$

CREATE TABLE `deportespista` (
  `ID_DeportesPista` int(11) NOT NULL,
  `ID_Pista` int(11) DEFAULT NULL,
  `ID_Deportes` int(11) DEFAULT NULL,
  `Precio` double DEFAULT NULL,
  `PrecioFederado` double DEFAULT NULL,
  `SuplementoLuz` double DEFAULT NULL,
  `MaxReserva` int(11) DEFAULT NULL,
  `Activo` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`ID_DeportesPista`),
  KEY `FK_Deportes` (`ID_Deportes`),
  KEY `FK_Pista` (`ID_Pista`),
  CONSTRAINT `FK_Deportes` FOREIGN KEY (`ID_Deportes`) REFERENCES `deportes` (`ID_Deportes`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_Pista` FOREIGN KEY (`ID_Pista`) REFERENCES `pista` (`ID_Pista`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1$$

delimiter $$

CREATE TABLE `federado` (
  `ID_Federado` int(11) NOT NULL,
  `ID_Usuario` int(11) DEFAULT NULL,
  `Verificado` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`ID_Federado`),
  KEY `FK_USUARIO2` (`ID_Usuario`),
  CONSTRAINT `FK_USUARIO2` FOREIGN KEY (`ID_Usuario`) REFERENCES `usuario` (`ID_Usuario`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1$$

delimiter $$

CREATE TABLE `permisos` (
  `ID_Permisos` int(11) NOT NULL,
  `Descripcion` text,
  `Activo` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`ID_Permisos`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1$$

delimiter $$

CREATE TABLE `pista` (
  `ID_Pista` int(11) NOT NULL AUTO_INCREMENT,
  `ID_CentroDeportivo` int(11) DEFAULT NULL,
  `Descripcion` text,
  `Hora_Ini` datetime DEFAULT NULL,
  `Hora_Fin` datetime DEFAULT NULL,
  `Hora_luz` datetime DEFAULT NULL,
  `Luz` tinyint(1) DEFAULT NULL,
  `Activo` tinyint(1) DEFAULT NULL,
  `Hora_luz_ini` datetime DEFAULT NULL,
  PRIMARY KEY (`ID_Pista`),
  KEY `FK_CentroDeportivo` (`ID_CentroDeportivo`),
  CONSTRAINT `FK_CentroDeportivo` FOREIGN KEY (`ID_CentroDeportivo`) REFERENCES `centrodeportivo` (`ID_CentroDeportivo`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1$$

delimiter $$

CREATE TABLE `reservas` (
  `ID_Reservas` int(11) NOT NULL,
  `ID_Usuario` int(11) DEFAULT NULL,
  `ID_DeportesPista` int(11) DEFAULT NULL,
  `Hora_Ini` datetime DEFAULT NULL,
  `Hora_Fin` datetime DEFAULT NULL,
  `Activo` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`ID_Reservas`),
  KEY `FK_Usuario` (`ID_Usuario`),
  KEY `FK_DeportesPista` (`ID_DeportesPista`),
  CONSTRAINT `FK_DeportesPista` FOREIGN KEY (`ID_DeportesPista`) REFERENCES `deportespista` (`ID_DeportesPista`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_Usuario` FOREIGN KEY (`ID_Usuario`) REFERENCES `usuario` (`ID_Usuario`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1$$

delimiter $$

CREATE TABLE `usuario` (
  `ID_Usuario` int(11) NOT NULL AUTO_INCREMENT,
  `Nombre` text,
  `Apellido` text,
  `Apellido2` text,
  `DNI` varchar(10) DEFAULT NULL,
  `Usuario` varchar(45) DEFAULT NULL,
  `Password` varchar(45) DEFAULT NULL,
  `Fx_registro` datetime DEFAULT NULL,
  `ID_Permisos` int(11) DEFAULT NULL,
  `Activo` tinyint(1) DEFAULT NULL,
  `Email` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`ID_Usuario`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1$$


Verificado